#pragma once

#include"IEventManager.h"
#include<list>

class IEventListener;
struct SEventData_MouseEvent;

enum EMouseEventClasses
{
	eME_Move,
	eME_ButtonClicked,
	eME_ButtonReleased,
	eME_WheelV,
};

enum EMouseButton
{
	eMB_Left = 1, 
	eMB_Right = 1 << 1, 
	eMB_Middle = 1 << 2,
	eMB_X1 = 1 << 3,
	eMB_X2 = 1 << 4,
};

#define g_PG_pMouseInputManager g_PG_pPaleGemFramework->GetMouseInputManager()

class PALEGEM_API pgMouseInputManager : public IEventManager
{
public:

	pgMouseInputManager();
	~pgMouseInputManager();

	// IEventManager

	void Update(float frameTime);
	void RegisterListener(IEventListener *listener, EVENT_CLASS eventClass = EC_UNKNOWN, EVENT_NAME eventName = E_UNKNOWN);
	void UnregisterListener(IEventListener *listener);
	void RegisterEvent(int eventName, int eventClass, IEventData *pData);
	void ShutDown();

	// _IEventManager

	bool IsButtonPressed(int id);
	bool IsButtonTapped(int id);

private:

	void DispatchEvent();
	
	void ProcessMovement(int lParam);
	void ProcessButtons(int buttonId, int activationMode);

	std::list<IEventListener*> m_listeners;
	std::map<BYTE, int> m_keyMap;
	SEventData_MouseEvent *m_pEventData;
	IEvent *m_pEvent;

	int m_nLastX;
	int m_nLastY;
	int m_nButtonStates;
};
